00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef TINYXML_INCLUDED
00034 #define TINYXML_INCLUDED
00035
00036 #ifdef _MSC_VER
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040
00041 #include <cctype>
00042 #include <cstdio>
00043 #include <cstdlib>
00044 #include <cstring>
00045 #include <cassert>
00046 #include <deque>
00047
00048
00049 #if defined( _DEBUG ) && !defined( DEBUG )
00050 #define DEBUG
00051 #endif
00052
00053 #if defined( DEBUG ) && defined( _MSC_VER )
00054 #include <windows.h>
00055 #define TIXML_LOG OutputDebugString
00056 #else
00057 #define TIXML_LOG printf
00058 #endif
00059
00060 #ifdef TIXML_USE_STL
00061 #include <string>
00062 #include <iostream>
00063
00064 #define TIXML_STRING std::string
00065 #define TIXML_ISTREAM std::istream
00066 #define TIXML_OSTREAM std::ostream
00067 #else
00068 #include "tinystr.h"
00069 #define TIXML_STRING TiXmlString
00070 #define TIXML_OSTREAM TiXmlOutStream
00071 #endif
00072
00073 class TiPullXmlDocument;
00074 class TiPullXmlElement;
00075 class TiPullXmlComment;
00076 class TiPullXmlUnknown;
00077 class TiPullXmlAttribute;
00078 class TiPullXmlText;
00079 class TiPullXmlDeclaration;
00080
00081 class TiPullXmlParsingData;
00082
00083
00084
00085
00086 struct TiPullXmlCursor
00087 {
00088 TiPullXmlCursor() { Clear(); }
00089 TiPullXmlCursor(int pos) : filepos(pos) { }
00090 void Clear() { filepos = -1; }
00091 bool operator==(const TiPullXmlCursor& ref) const
00092 { return (filepos == ref.filepos); }
00093
00094 int filepos;
00095 };
00096
00097
00098
00099 enum
00100 {
00101 TIXML_SUCCESS,
00102 TIXML_NO_ATTRIBUTE,
00103 TIXML_WRONG_TYPE
00104 };
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class TiPullXmlBase
00129 {
00130 friend class TiPullXmlNode;
00131 friend class TiPullXmlElement;
00132 friend class TiPullXmlDocument;
00133
00134 public:
00135 TiPullXmlBase() {}
00136 virtual ~TiPullXmlBase() {}
00137
00138 struct ParsePosition
00139 {
00140 ParsePosition() : data(0), pos(0) { }
00141 ParsePosition(const char* data_, int pos_) : data(data_), pos(pos_) { }
00142 const char* data;
00143 TiPullXmlCursor pos;
00144 };
00145
00146
00147
00148
00149
00150
00151 virtual void Print( FILE* cfile, int depth ) const = 0;
00152
00153
00154
00155
00156
00157
00158
00159 static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
00160
00161
00162 static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
00163
00164 protected:
00165
00166
00167 class StringToBuffer
00168 {
00169 public:
00170 StringToBuffer( const TIXML_STRING& str );
00171 ~StringToBuffer();
00172 char* buffer;
00173 };
00174
00175 inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); }
00176
00177 virtual void StreamOut (TIXML_OSTREAM *) const = 0;
00178
00179 #ifdef TIXML_USE_STL
00180 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
00181 static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
00182 #endif
00183
00184
00185
00186
00187
00188 static const char* ReadName( const char* p, TIXML_STRING* name );
00189
00190
00191
00192
00193 static const char* ReadText( const char* in,
00194 TIXML_STRING* text,
00195 bool ignoreWhiteSpace,
00196 const char* endTag,
00197 bool ignoreCase );
00198
00199 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway ) = 0;
00200
00201
00202 static const char* GetEntity( const char* in, char* value );
00203
00204
00205 inline static const char* GetChar( const char* p, char* _value )
00206 {
00207 assert( p );
00208 if ( *p == '&' )
00209 {
00210 return GetEntity( p, _value );
00211 }
00212 else
00213 {
00214 *_value = *p;
00215 return p+1;
00216 }
00217 }
00218
00219
00220
00221 static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
00222
00223 static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
00224
00225
00226 static bool StringEqual( const char* p,
00227 const char* endTag,
00228 bool ignoreCase );
00229
00230
00231 enum
00232 {
00233 TIXML_NO_ERROR = 0,
00234 TIXML_ERROR,
00235 TIXML_ERROR_OPENING_FILE,
00236 TIXML_ERROR_OUT_OF_MEMORY,
00237 TIXML_ERROR_PARSING_ELEMENT,
00238 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00239 TIXML_ERROR_READING_ELEMENT_VALUE,
00240 TIXML_ERROR_READING_ATTRIBUTES,
00241 TIXML_ERROR_PARSING_EMPTY,
00242 TIXML_ERROR_READING_END_TAG,
00243 TIXML_ERROR_PARSING_UNKNOWN,
00244 TIXML_ERROR_PARSING_COMMENT,
00245 TIXML_ERROR_PARSING_DECLARATION,
00246 TIXML_ERROR_DOCUMENT_EMPTY,
00247
00248 TIXML_ERROR_STRING_COUNT
00249 };
00250 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00251
00252 TiPullXmlCursor startPos;
00253
00254 private:
00255 struct Entity
00256 {
00257 const char* str;
00258 unsigned int strLength;
00259 char chr;
00260 };
00261 enum
00262 {
00263 NUM_ENTITY = 5,
00264 MAX_ENTITY_LENGTH = 6
00265
00266 };
00267 static Entity entity[ NUM_ENTITY ];
00268 static bool condenseWhiteSpace;
00269 };
00270
00271
00272
00273
00274
00275
00276
00277
00278 class TiPullXmlNode : public TiPullXmlBase
00279 {
00280 friend class TiPullXmlDocument;
00281 friend class TiPullXmlElement;
00282
00283 public:
00284 #ifdef TIXML_USE_STL
00285
00286
00287
00288
00289 friend std::istream& operator >> (std::istream& in, TiPullXmlNode& base);
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 friend std::ostream& operator<< (std::ostream& out, const TiPullXmlNode& base);
00308
00309
00310 friend std::string& operator<< (std::string& out, const TiPullXmlNode& base );
00311
00312 #else
00313
00314 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiPullXmlNode& base);
00315 #endif
00316
00317
00318
00319
00320 enum NodeType
00321 {
00322 DOCUMENT,
00323 ELEMENT,
00324 COMMENT,
00325 UNKNOWN,
00326 TEXT,
00327 DECLARATION,
00328 TYPECOUNT
00329 };
00330
00331 virtual ~TiPullXmlNode();
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 const char * Value() const { return value.c_str (); }
00346
00347 void SetValue(const char* val) {}
00348 #ifdef TIXML_USE_STL
00349 void SetValue(const std::string& _value) {}
00350 #endif
00351
00352 TiPullXmlNode* LinkActiveChild(TiPullXmlNode* node);
00353
00354
00355 TiPullXmlNode* Parent() const { return parent; }
00356
00357 TiPullXmlNode* FirstChild( );
00358
00359 TiPullXmlNode* FirstChild( const char * value, NodeType _type );
00360
00361 #ifdef TIXML_USE_STL
00362 TiPullXmlNode* FirstChild( const std::string& _value, NodeType _type )
00363 { return FirstChild (_value.c_str(), _type); }
00364 #endif
00365
00366 TiPullXmlNode* NextSibling( ) ;
00367
00368
00369 TiPullXmlNode* NextSibling( const char * _value, NodeType _type ) ;
00370
00371 #ifdef TIXML_USE_STL
00372 TiPullXmlNode* NextSibling( const std::string& _value, NodeType _type )
00373 { return NextSibling (_value.c_str(), _type); }
00374 #endif
00375
00376
00377
00378
00379
00380 TiPullXmlElement* NextSiblingElement( ) ;
00381 TiPullXmlElement* NextSiblingElement( const char * _value )
00382 { TiPullXmlNode* n = NextSibling(_value, ELEMENT); return n ? n->ToElement() : 0; }
00383
00384 #ifdef TIXML_USE_STL
00385 TiPullXmlElement* NextSiblingElement( const std::string& _value)
00386 { return NextSiblingElement (_value.c_str ()); }
00387 #endif
00388
00389
00390 TiPullXmlElement* FirstChildElement( ) ;
00391
00392
00393 TiPullXmlElement* FirstChildElement( const char * _value )
00394 { TiPullXmlNode* n = FirstChild(_value, ELEMENT); return n ? n->ToElement() : 0; }
00395
00396 #ifdef TIXML_USE_STL
00397 TiPullXmlElement* FirstChildElement( const std::string& _value ) const
00398 { return FirstChildElement (_value.c_str ()); }
00399 #endif
00400
00401
00402
00403
00404
00405 virtual NodeType Type() const { return type; }
00406
00407 bool hasChildren() const { return (endPosOpen.filepos >= 0); }
00408
00409
00410
00411
00412 TiPullXmlDocument* GetDocument() const;
00413
00414 TiPullXmlDocument* ToDocument()const { return ( this && type == DOCUMENT ) ? (TiPullXmlDocument*) this : 0; }
00415 TiPullXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiPullXmlElement*) this : 0; }
00416 TiPullXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiPullXmlComment*) this : 0; }
00417 TiPullXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiPullXmlUnknown*) this : 0; }
00418 TiPullXmlText* ToText() const { return ( this && type == TEXT ) ? (TiPullXmlText*) this : 0; }
00419 TiPullXmlDeclaration* ToDeclaration()const { return ( this && type == DECLARATION ) ? (TiPullXmlDeclaration*) this : 0; }
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 int Row() const;
00440 int Column() const;
00441
00442 protected:
00443 TiPullXmlNode( NodeType type );
00444
00445 #ifdef TIXML_USE_STL
00446
00447 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
00448 #endif
00449
00450
00451 TiPullXmlNode* Identify( const char* start ) const;
00452
00453 bool FindElementClose(ParsePosition in, const char* &out);
00454
00455
00456 TIXML_STRING SValue() const { return value ; }
00457
00458 TiPullXmlNode* parent;
00459 TiPullXmlNode* activeChild;
00460 NodeType const type;
00461
00462 TiPullXmlCursor endPosOpen;
00463 TiPullXmlCursor endPosClose;
00464
00465 TIXML_STRING value;
00466 };
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476 class TiPullXmlAttribute : public TiPullXmlBase
00477 {
00478 friend class TiPullXmlAttributeSet;
00479
00480 public:
00481
00482 TiPullXmlAttribute()
00483 {
00484 document = 0;
00485 prev = next = 0;
00486 }
00487
00488 #ifdef TIXML_USE_STL
00489
00490 TiPullXmlAttribute( const std::string& _name, const std::string& _value )
00491 {
00492 name = _name;
00493 value = _value;
00494 document = 0;
00495 prev = next = 0;
00496 }
00497 #endif
00498
00499
00500 TiPullXmlAttribute( const char * _name, const char * _value )
00501 {
00502 name = _name;
00503 value = _value;
00504 document = 0;
00505 prev = next = 0;
00506 }
00507
00508 const char* Name() const { return name.c_str (); }
00509 const char* Value() const { return value.c_str (); }
00510 const int IntValue() const;
00511 const double DoubleValue() const;
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522 int QueryIntValue( int* value ) const;
00523
00524 int QueryDoubleValue( double* value ) const;
00525
00526 void SetName( const char* _name ) { name = _name; }
00527 void SetValue( const char* _value ) { value = _value; }
00528
00529 void SetIntValue( int value );
00530 void SetDoubleValue( double value );
00531
00532 #ifdef TIXML_USE_STL
00533
00534 void SetName( const std::string& _name )
00535 {
00536 StringToBuffer buf( _name );
00537 SetName ( buf.buffer ? buf.buffer : "error" );
00538 }
00539
00540 void SetValue( const std::string& _value )
00541 {
00542 StringToBuffer buf( _value );
00543 SetValue( buf.buffer ? buf.buffer : "error" );
00544 }
00545 #endif
00546
00547
00548 TiPullXmlAttribute* Next() const;
00549
00550 TiPullXmlAttribute* Previous() const;
00551
00552 bool operator==( const TiPullXmlAttribute& rhs ) const { return rhs.name == name; }
00553 bool operator<( const TiPullXmlAttribute& rhs ) const { return name < rhs.name; }
00554 bool operator>( const TiPullXmlAttribute& rhs ) const { return name > rhs.name; }
00555
00556
00557
00558
00559
00560 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00561
00562
00563 virtual void Print( FILE* cfile, int depth ) const;
00564
00565 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00566
00567
00568 void SetDocument( TiPullXmlDocument* doc ) { document = doc; }
00569
00570 private:
00571 TiPullXmlDocument* document;
00572 TIXML_STRING name;
00573 TIXML_STRING value;
00574 TiPullXmlAttribute* prev;
00575 TiPullXmlAttribute* next;
00576 };
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 class TiPullXmlAttributeSet
00592 {
00593 public:
00594 TiPullXmlAttributeSet();
00595 ~TiPullXmlAttributeSet();
00596
00597 void Add( TiPullXmlAttribute* attribute );
00598 void Remove( TiPullXmlAttribute* attribute );
00599
00600 TiPullXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00601 TiPullXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00602 TiPullXmlAttribute* Find( const char * name ) const;
00603
00604 private:
00605 TiPullXmlAttribute sentinel;
00606 };
00607
00608
00609
00610
00611
00612
00613 class TiPullXmlElement : public TiPullXmlNode
00614 {
00615 public:
00616
00617 TiPullXmlElement (const char * in_value);
00618
00619 #ifdef TIXML_USE_STL
00620
00621 TiPullXmlElement( const std::string& _value ) : TiPullXmlNode( TiPullXmlNode::ELEMENT )
00622 {
00623 firstChild = lastChild = 0;
00624 value = _value;
00625 }
00626 #endif
00627
00628 virtual ~TiPullXmlElement();
00629
00630
00631
00632
00633 const char* Attribute( const char* name ) const;
00634
00635
00636
00637
00638
00639
00640
00641 const char* Attribute( const char* name, int* i ) const;
00642
00643
00644
00645
00646
00647
00648
00649 const char* Attribute( const char* name, double* d ) const;
00650
00651
00652
00653
00654
00655
00656
00657
00658 int QueryIntAttribute( const char* name, int* value ) const;
00659
00660 int QueryDoubleAttribute( const char* name, double* value ) const;
00661
00662 #ifdef TIXML_USE_STL
00663 const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); }
00664 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); }
00665 #endif
00666
00667 TiPullXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
00668 TiPullXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
00669
00670
00671
00672 virtual void Print( FILE* cfile, int depth ) const;
00673
00674 protected:
00675
00676
00677 #ifdef TIXML_USE_STL
00678 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00679 #endif
00680 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00681
00682
00683
00684
00685
00686 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00687
00688 private:
00689 TiPullXmlAttributeSet attributeSet;
00690 };
00691
00692
00693
00694
00695 class TiPullXmlComment : public TiPullXmlNode
00696 {
00697 public:
00698
00699 TiPullXmlComment() : TiPullXmlNode( TiPullXmlNode::COMMENT ) {}
00700 virtual ~TiPullXmlComment() {}
00701
00702
00703 virtual void Print( FILE* cfile, int depth ) const;
00704 protected:
00705
00706 #ifdef TIXML_USE_STL
00707 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00708 #endif
00709 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00710
00711
00712
00713
00714 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00715 };
00716
00717
00718
00719
00720 class TiPullXmlText : public TiPullXmlNode
00721 {
00722 friend class TiPullXmlElement;
00723 public:
00724 TiPullXmlText( ) : TiPullXmlNode (TiPullXmlNode::TEXT)
00725 { }
00726
00727 TiPullXmlText (const char * initValue) : TiPullXmlNode (TiPullXmlNode::TEXT)
00728 { SetValue( initValue ); }
00729 virtual ~TiPullXmlText() {}
00730
00731 #ifdef TIXML_USE_STL
00732
00733 TiPullXmlText( const std::string& initValue ) : TiPullXmlNode (TiPullXmlNode::TEXT)
00734 { SetValue( initValue ); }
00735 #endif
00736
00737
00738 virtual void Print( FILE* cfile, int depth ) const;
00739
00740 protected :
00741 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00742
00743 bool Blank() const;
00744
00745
00746
00747
00748 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00749
00750 #ifdef TIXML_USE_STL
00751 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00752 #endif
00753 };
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769 class TiPullXmlDeclaration : public TiPullXmlNode
00770 {
00771 public:
00772
00773 TiPullXmlDeclaration() : TiPullXmlNode( TiPullXmlNode::DECLARATION ) {}
00774
00775 #ifdef TIXML_USE_STL
00776
00777 TiPullXmlDeclaration( const std::string& _version,
00778 const std::string& _encoding,
00779 const std::string& _standalone )
00780 : TiPullXmlNode( TiPullXmlNode::DECLARATION )
00781 {
00782 version = _version;
00783 encoding = _encoding;
00784 standalone = _standalone;
00785 }
00786 #endif
00787
00788
00789 TiPullXmlDeclaration( const char* _version,
00790 const char* _encoding,
00791 const char* _standalone );
00792
00793 virtual ~TiPullXmlDeclaration() {}
00794
00795
00796 const char * Version() const { return version.c_str (); }
00797
00798 const char * Encoding() const { return encoding.c_str (); }
00799
00800 const char * Standalone() const { return standalone.c_str (); }
00801
00802
00803 virtual void Print( FILE* cfile, int depth ) const;
00804
00805 protected:
00806
00807 #ifdef TIXML_USE_STL
00808 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00809 #endif
00810 virtual void StreamOut ( TIXML_OSTREAM * out) const;
00811
00812
00813
00814
00815 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00816
00817 private:
00818 TIXML_STRING version;
00819 TIXML_STRING encoding;
00820 TIXML_STRING standalone;
00821 };
00822
00823
00824
00825
00826
00827
00828
00829 class TiPullXmlUnknown : public TiPullXmlNode
00830 {
00831 public:
00832 TiPullXmlUnknown() : TiPullXmlNode( TiPullXmlNode::UNKNOWN ) {}
00833 virtual ~TiPullXmlUnknown() {}
00834
00835
00836 virtual void Print( FILE* cfile, int depth ) const;
00837 protected:
00838 #ifdef TIXML_USE_STL
00839 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00840 #endif
00841 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00842
00843
00844
00845
00846 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00847 };
00848
00849
00850
00851
00852
00853
00854 class TiPullXmlDocument : public TiPullXmlNode
00855 {
00856 friend class TiPullXmlNode;
00857 public:
00858
00859 TiPullXmlDocument();
00860
00861 TiPullXmlDocument( const char * documentName );
00862
00863 #ifdef TIXML_USE_STL
00864
00865 TiPullXmlDocument( const std::string& documentName ) :
00866 TiPullXmlNode( TiPullXmlNode::DOCUMENT )
00867 {
00868 value = documentName;
00869 error = false;
00870 }
00871 #endif
00872
00873 virtual ~TiPullXmlDocument() {}
00874
00875
00876
00877
00878
00879 bool LoadFile();
00880
00881 bool SaveFile() const;
00882
00883 bool LoadFile( const char * filename );
00884
00885 bool SaveFile( const char * filename ) const;
00886
00887 #ifdef TIXML_USE_STL
00888 bool LoadFile( const std::string& filename )
00889 {
00890 StringToBuffer f( filename );
00891 return ( f.buffer && LoadFile( f.buffer ));
00892 }
00893 bool SaveFile( const std::string& filename ) const
00894 {
00895 StringToBuffer f( filename );
00896 return ( f.buffer && SaveFile( f.buffer ));
00897 }
00898 #endif
00899
00900
00901
00902 virtual bool Parse( ParsePosition in, const char* &out, bool throwaway );
00903
00904
00905
00906
00907
00908 TiPullXmlElement* RootElement() { return FirstChildElement(); }
00909
00910
00911
00912
00913
00914
00915 bool Error() const { return error; }
00916
00917
00918 const char * ErrorDesc() const { return errorDesc.c_str (); }
00919
00920
00921
00922
00923 const int ErrorId() const { return errorId; }
00924
00925
00926
00927
00928
00929
00930
00931
00932 int ErrorRow() const;
00933 int ErrorCol() const;
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955 void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
00956
00957 int TabSize() const { return tabsize; }
00958
00959
00960
00961
00962 void ClearError() { error = false;
00963 errorId = 0;
00964 errorDesc = "";
00965 errorLocation.Clear();
00966
00967 }
00968
00969
00970 void Print() const { Print( stdout, 0 ); }
00971
00972
00973 virtual void Print( FILE* cfile, int depth = 0 ) const;
00974
00975 void SetError( int err, const char* errorLocation, TiPullXmlParsingData* prevData );
00976
00977 const char* getFileBuffer() const { return fileBuffer; }
00978 void setFileBuffer(const char* buf) { fileBuffer = buf; }
00979
00980 protected :
00981 virtual void StreamOut ( TIXML_OSTREAM * out) const;
00982 #ifdef TIXML_USE_STL
00983 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00984 #endif
00985
00986 void FindAllLineStarts( const char* p );
00987 int FindLine(TiPullXmlCursor location) const;
00988
00989 private:
00990 bool error;
00991 int errorId;
00992 TIXML_STRING errorDesc;
00993 int tabsize;
00994 TiPullXmlCursor errorLocation;
00995 std::deque<int> lineStarts;
00996 const char* fileBuffer;
00997 };
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080 class TiPullXmlHandle
01081 {
01082 public:
01083
01084 TiPullXmlHandle( TiPullXmlNode* node ) { this->node = node; }
01085
01086 TiPullXmlHandle( const TiPullXmlHandle& ref ) { this->node = ref.node; }
01087
01088
01089 TiPullXmlHandle FirstChild() const;
01090
01091 TiPullXmlHandle FirstChild( const char * value, TiPullXmlNode::NodeType nType ) const;
01092
01093 TiPullXmlHandle FirstChildElement() const;
01094
01095 TiPullXmlHandle FirstChildElement( const char * value ) const;
01096
01097
01098
01099
01100
01101
01102
01103
01104 TiPullXmlHandle Child( int index ) const;
01105
01106
01107
01108
01109 TiPullXmlHandle ChildElement( const char* value, int index ) const;
01110
01111
01112
01113
01114 TiPullXmlHandle ChildElement( int index ) const;
01115
01116 #ifdef TIXML_USE_STL
01117 TiPullXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
01118 TiPullXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
01119
01120 TiPullXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
01121 TiPullXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
01122 #endif
01123
01124
01125 TiPullXmlNode* Node() const { return node; }
01126
01127 TiPullXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01128
01129 TiPullXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01130
01131 private:
01132 TiPullXmlNode* node;
01133 };
01134
01135
01136 typedef TiPullXmlDocument TiXmlDocument;
01137 typedef TiPullXmlElement TiXmlElement;
01138 typedef TiPullXmlComment TiXmlComment;
01139 typedef TiPullXmlUnknown TiXmlUnknown;
01140 typedef TiPullXmlAttribute TiXmlAttribute;
01141 typedef TiPullXmlText TiXmlText;
01142 typedef TiPullXmlDeclaration TiXmlDeclaration;
01143 typedef TiPullXmlHandle TiXmlHandle;
01144
01145
01146
01147 #endif // TINYXML_INCLUDED
01148